import React from 'react';
import {View,Text} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { useNavigation,useRoute,useNavigationState,useFocusEffect,useIsFocused } from '@react-navigation/native';
import { useStores } from 'src/store';
// hooks的方式
function HooksTest() {
  const insets = useSafeAreaInsets()
  // 获取navigation对象
  const navigation = useNavigation()
  // 获取当前route的对象
  const route = useRoute()
  // 获取当前路由的导航状态
  const navigationState = useNavigationState(state => state)
  // 屏幕聚焦
  useFocusEffect(React.useCallback(()=>{
    // console.log("pingmu 聚焦了")
    return 
  },[]))
  const isFocused = useIsFocused();
  const { localStore } = useStores()
  localStore.getTokens()
  const login = async ()=>{
    await localStore.setToken("sdfdffsdsd")
  } 
  return (
    <View style={{
      paddingTop:insets.top,
      paddingBottom:insets.bottom,
      flex: 1,
      alignItems: 'center',
    }}> 
      <Text>Hooks测试</Text>
      <Text onPress={()=>login()}>是的我登录了</Text>
    </View>
  );
}

export default HooksTest;